import Vue from 'vue'
import Router from 'vue-router'
import login from '@/pages/review/login'
import pdf from '@/pages/review/pdf'
import reviewerHome from '@/pages/review/reviewerHome'
import student from '@/pages/review/student'
import result from '@/pages/review/result'
import resMessage from '@/pages/review/resMessage'
import stuMessage from '@/pages/review/stuMessage'


Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      name: '首页',
      component: login,
      //redirect:'/userHome/personMessage',
    },
    {
      path: '/pdf',
      name: '首页',
      component: pdf,
      //redirect:'/userHome/personMessage',
    },
    {
      path: '/reviewerHome',
      name: 'reviewerHome',
      component: reviewerHome,
      redirect:'/reviewerHome/student',
      children:[
          {path:'/reviewerHome/student',component:student,name:'学生信息',show:true,iconCls: 'el-icon-menu'},
          //{path:'/reviewerHome/result',component:pdf,name:'评审结果',show:true,iconCls: 'el-icon-edit-outline'},
          {path:'/reviewerHome/resMessage',component:resMessage},
          {path:'/reviewerHome/stuMessage',component:stuMessage},
      ]
    }

  ]
})

// router.beforeEach((to, from, next) => {
//     if (to.path.startsWith('/login')) {
//       window.sessionStorage.removeItem('access-user')
//       next()
//     } 
//     else {
//       if(to.path.startsWith('/userHome')){
//         let user = JSON.parse(window.sessionStorage.getItem('access-user'))
//         if (!user) {
//           next({path: '/login'})
//         } else {
//           next()
//         }
//       }else{
//         next()
//       }
//     }
// })

export default router